package hypeerweb;
import java.util.*;

public abstract class ConnectionsModifier {
	public ConnectionsModifier() {}
	
	public Node execute(Node target, Node startingNode) {
		Node modifyingNode = getModifyingNode(startingNode);
		refreshConnections(modifyingNode);
		setWebId(target, modifyingNode, startingNode);
		modifyConnections(target, modifyingNode, startingNode);
		for(NodeDelegate n: getAllConnections(target, modifyingNode)) {
			modifyConnection(target, n, modifyingNode, startingNode);
		}
		return finalizeConnections(target, modifyingNode, startingNode);
	}
	
	public abstract void refreshConnections(Node modifyingNode);
	
	public abstract void modifyConnection(Node target, NodeDelegate connection, Node modifyingNode, Node replacingNode);
	
	public abstract ArrayList<NodeDelegate> getAllConnections(Node target, Node deletionNode);
	
	public abstract Node getModifyingNode(Node node);
	
	public abstract void setWebId(Node node, Node modifyingNode, Node replacingNode);
	
	public abstract void modifyConnections(Node target, Node modifyingNode, Node replacingNode);
	
	public abstract Node finalizeConnections(Node target, Node modifyingNode, Node replacingNode);
}
